<template>
  <img src="./img/bg.png" alt="" class="bg" />
  <div class="topSitting">头部占位</div>
  <div class="houseInfo" v-for="(item, index) in houseList" :key="index">
    <div class="infoTitle">房产信息</div>
    <img src="./img/daban_bg.png" alt="" class="infoTitleBg" />
    <div class="infoTips">图片数量(4)</div>
    <div class="infoIem">
      <div class="title">房产类型</div>
      <div class="value">{{ item.houseType }}</div>
    </div>
    <div class="infoIem">
      <div class="title">房屋坐落</div>
      <div class="value">{{ item.address }}</div>
    </div>
    <div class="infoIem">
      <div class="title">权利属性</div>
      <div class="value">{{ item.ownershipType }}</div>
    </div>
    <div class="infoIem">
      <div class="title">抵押状态</div>
      <div class="value">{{ item.pledgeStatus }}</div>
    </div>
    <div class="infoIem">
      <div class="title">面积</div>
      <div class="value">{{ item.houseArea }}</div>
    </div>
    <div class="bottomBtnArea">
      <div class="btn delete" @click="deleteHouse(item.id)">删除</div>
      <div class="btn check" @click="checkHouse(item.id)">查看</div>
    </div>
  </div>
  <div class="addArea" @click="addHouse">
    <img src="./img/new_icon.png" alt="" class="icon" />
    <div>新增</div>
  </div>
</template>

<script setup>
import { ref, reactive } from "vue";
import * as http from "../../utils/http";
import { onLoad } from "@dcloudio/uni-app";
const houseList = reactive([]);
let param = null;
onLoad((option) => {
  param = JSON.parse(option.value);
  http.creditHouseList({ orderId: param.orderId }).then((res) => {
    houseList.push(...res.data);
  });
});
// 删除
const deleteHouse = (id) => {
  http
    .creditHouseDelete({ id })
    .then((res) => {
      wx.showToast({
        title: "删除成功",
        icon: "none",
        duration: 1000,
        mask: true,
      });
    })
    .catch((err) => {
      wx.showToast({
        title: "删除失败",
        icon: "none",
        duration: 1000,
        mask: true,
      });
    });
};
// 查看
const checkHouse = (id) => {
  let param = {
    isCheck: true,
    id,
  };
  wx.navigateTo({
    url: "../fcInfo/fcInfo?value=" + JSON.stringify(param),
  });
};
// 新增
const addHouse = () => {
  let params = {
    isCheck: false,
    orderId: param.orderId,
  };
  console.log(params);
  wx.navigateTo({
    url: "../fcInfo/fcInfo?value=" + JSON.stringify(params),
  });
};
</script>

<style scoped lang="scss">
.bg {
  width: 750rpx;
  height: 863rpx;
  position: absolute;
  left: 0;
  top: 0;
  z-index: -999999;
}
.topSitting {
  height: 50rpx;
  opacity: 0;
}
.houseInfo {
  margin: 30rpx 28rpx;
  background-color: #fff;
  border-radius: 16rpx;
  padding: 0 30rpx;
  padding-top: 112rpx;
  padding-bottom: 153rpx;
  position: relative;
  font-size: 28rpx;
  box-shadow: 0rpx 4rpx 13rpx 0rpx #e0e4ff;
  .infoTitle {
    width: 260rpx;
    height: 45rpx;
    line-height: 45rpx;
    text-align: center;
    font-size: 28rpx;
    color: #fff;
    position: absolute;
    left: 50%;
    transform: translate(-50%);
    top: 0;
    z-index: 99;
  }
  .infoTitleBg {
    width: 260rpx;
    height: 45rpx;
    position: absolute;
    left: 50%;
    transform: translate(-50%);
    top: 0;
    z-index: 9;
  }
  .infoTips {
    position: absolute;
    left: 50%;
    transform: translate(-50%);
    top: 68rpx;
    color: #3277f2;
  }
  .infoIem {
    height: 90rpx;
    border-bottom: 1rpx solid #eeeeee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .title {
      color: #666666;
    }
    .value {
      color: #999999;
    }
  }
  .bottomBtnArea {
    display: flex;
    position: absolute;
    left: 50%;
    bottom: 46rpx;
    transform: translate(-50%);
    .btn {
      width: 153rpx;
      height: 60rpx;
      line-height: 60rpx;
      text-align: center;
      border-radius: 29rpx;
      margin: 0 15rpx;
    }
    .delete {
      color: #ff4545;
      border: 1rpx solid #ff3737;
    }
    .check {
      color: #3277f2;
      border: 1rpx solid #598bdc;
    }
  }
}
.addArea {
  height: 150rpx;
  margin: 30rpx 24rpx;
  border: 1rpx dashed #3483fb;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fff;
  border-radius: 12rpx;
  font-size: 24rpx;
  color: #2f80fb;
  .icon {
    width: 30rpx;
    height: 30rpx;
    margin-right: 30rpx;
  }
}
</style>
